package com.dk.service.impl;

import com.dk.model.Client;
import com.dk.mapper.ClientMapper;
import com.dk.service.ClientService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dk.vo.ClientVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wbh
 * @since 2023-03-17
 */
@Service
public class ClientServiceImpl extends ServiceImpl<ClientMapper, Client> implements ClientService {
    @Resource
    private ClientMapper clientMapper;

    @Override
    public List<ClientVO> getAll() {
        return  clientMapper.selectList(null).stream().map(client -> {
            ClientVO vo = new ClientVO();
            BeanUtils.copyProperties(client,vo);
            return vo;
        }).collect(Collectors.toList());
    }
}
